package errorHandle;

import baseClass.ErrorToken;
import log4Compile.Log;
import org.antlr.v4.runtime.*;
/*
    重新的词法错误处理类
    2022-3-9-杨海南
 */
public class LexErrorHandle extends BaseErrorListener {
    @Override
    public void syntaxError(Recognizer<?, ?> recognizer,
                            Object offendingSymbol,
                            int line,//错误所在行号
                            int charPositionInLine,//错误在此行的第几个字符处
                            String msg,
                            RecognitionException e) {

        ErrorDeliver errorDeliver = ErrorDeliver.getErrorDeliverInstance();
        ErrorToken errorToken = new ErrorToken(line,charPositionInLine,msg);
        errorDeliver.addNewErrorToken(errorToken);
        System.err.println(msg);

    }

}
